package com.askyjt.videosearch.config;

import io.milvus.client.ConnectFailedException;
import io.milvus.client.ConnectParam;
import io.milvus.client.MilvusClient;
import io.milvus.client.MilvusGrpcClient;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @author yangjintao
 * milvus 相关配置类
 */
@Configuration
public class MilvusConfig {

    @Resource
    MilvusConfigProperties milvusConfigProperties;

    public MilvusClient getMilvusClient() throws ConnectFailedException {
        ConnectParam connectParam =
                new ConnectParam.Builder().withHost(milvusConfigProperties.getHost()).withPort(milvusConfigProperties.getPort()).build();
        MilvusClient client = new MilvusGrpcClient();
        client.connect(connectParam);
        return client;
    }
}
